﻿USE [tyajz]
GO

/****** Object:  Table [dbo].[Project]    Script Date: 2012/9/17 0:34:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Project](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Address] [nvarchar](100) NOT NULL,
	[EquipmentId] [int] NOT NULL,
	[ConstructionCompany] [nvarchar](100) NOT NULL,
	[ConstructionProjectManager] [nvarchar](100) NOT NULL,
	[ConstructionProjectManagerPhoneMobile] [nvarchar](100) NOT NULL,
	[DemolitionCompany] [nvarchar](100) NOT NULL,
	[DemolitionCompanyManager] [nvarchar](100) NOT NULL,
	[DemolitionCompanyManagerMobile] [nvarchar](100) NOT NULL,
	[InspectCompany] [nvarchar](100) NOT NULL,
	[InspectTime] [datetime] NULL,
	[InspectResult] [nvarchar](50) NOT NULL,
	[ConstructDateTime] [datetime] NOT NULL,
	[DemolitionDateTime] [datetime] NOT NULL,
	[High] [nvarchar](50) NOT NULL,
	[Status] [nvarchar](50) NOT NULL,
	[Comment] [nvarchar](max) NOT NULL,
	[HasPrinted] [bit] NOT NULL,
	[DriverId] [int] NULL,
	[SignalDriverId] [int] NULL,
	[ConstructionPermitNO] [nvarchar](50) NULL,
	[CreateDT] [datetime] NOT NULL,
	[ModifiedDT] [datetime] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
	[LastModifiedUser] [int] NOT NULL,
 CONSTRAINT [PK_Project] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[Project] ADD  CONSTRAINT [DF_Project_DriverId]  DEFAULT ((0)) FOR [DriverId]
GO

ALTER TABLE [dbo].[Project]  WITH CHECK ADD  CONSTRAINT [FK_Project_Driver] FOREIGN KEY([DriverId])
REFERENCES [dbo].[Driver] ([Id])
GO

ALTER TABLE [dbo].[Project] CHECK CONSTRAINT [FK_Project_Driver]
GO

ALTER TABLE [dbo].[Project]  WITH CHECK ADD  CONSTRAINT [FK_Project_Driver1] FOREIGN KEY([SignalDriverId])
REFERENCES [dbo].[Driver] ([Id])
GO

ALTER TABLE [dbo].[Project] CHECK CONSTRAINT [FK_Project_Driver1]
GO

ALTER TABLE [dbo].[Project]  WITH CHECK ADD  CONSTRAINT [FK_Project_Equipment] FOREIGN KEY([EquipmentId])
REFERENCES [dbo].[Equipment] ([Id])
GO

ALTER TABLE [dbo].[Project] CHECK CONSTRAINT [FK_Project_Equipment]
GO

ALTER TABLE [dbo].[Project]  WITH CHECK ADD  CONSTRAINT [FK_Project_User] FOREIGN KEY([LastModifiedUser])
REFERENCES [dbo].[User] ([Id])
GO

ALTER TABLE [dbo].[Project] CHECK CONSTRAINT [FK_Project_User]
GO


